/*
 * @Author: C.
 * @Date: 2023-02-02 13:14:40
 */
import { dateFm, timeFm } from './dateTime'
import { priceFm } from './math'
import { emptyFm } from './display'
export type FilterEnums = 'time' | 'date' | 'default' | 'amount'
type IFilter = {
  [key in FilterEnums]: {
    func: (a: any) => string
  }
}
export const filterMap: IFilter = {
  time: {
    func: ({ value }) => timeFm(value),
  },
  date: {
    func: ({ value }) => dateFm(value),
  },
  default: {
    func: ({ value }) => emptyFm(value),
  },
  amount: {
    func: ({ value }) => priceFm(value),
  },
}
export function dataFilter(value: any, type: FilterEnums = 'default'): string {
  return filterMap[type].func({ value })
}
